package cn.yuhh.api.manage.api;

import cn.yuhh.api.exception.ApiException;
import cn.yuhh.api.helper.ApiResponse;
import cn.yuhh.api.service.AbstractApiService;
import cn.yuhh.core.domain.User;
import cn.yuhh.core.type.Status;
import com.magic.spring.mongo.IMongoUpdate;
import com.magic.spring.mongo.Mongo;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author ysw
 * @create 2020-03-01-12:00
 * @descreption 删除
 **/
@Component("userDel1.0")
public class UserDelService extends AbstractApiService {
    @Override
    public Map service(Map request) {

        Mongo.buildMongo().eq("_id",id(request)).updateFirst(User.class, new IMongoUpdate() {
            @Override
            public void update(Update update) {
                update.set("status", Status.DEL);
                update.set("updateAt", System.currentTimeMillis() / 1000);
            }
        });
        return ApiResponse.success();
    }

}
